from asyncio import sleep

import requests
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.get('https://www.baidu.com/')

news_a = driver.find_element(By.XPATH, '//*[@id="s-top-left"]/a[1]')

news_a.click()

windows = driver.window_handles

driver.switch_to.window(windows[-1])

firstnews = driver.find_element(By.XPATH, '//*[@id="pane-news"]/div/ul/li[1]/strong/a')
print(firstnews)
print(firstnews.text)

sleep(5)
driver.quit()
